<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
/**
 * Prunus Damasco
 *
 * Contenedor Damasco
 *
 * @author		agosto
 * @date		  20090531
 * @version		0.1
 * @copyright	Copyright (c) 2009, 7dedos
 * @link		http://www.7dedos.com.ar
 */
class prunus_damasco
{
	protected $ci;
  protected $buffer;
  protected $offsetPosition;
  protected $title;
  protected $closeLabel;
  protected $triggerLabel;
  protected $msg;
    
	public function __construct()	{
		$this->ci =& get_instance();
    $this->ci->load->helper('form');
    $this->ci->load->config('prunus_damasco');
    $this->offsetPosition = $this->ci->config->item('PRDA_defaultOffset');
    $this->lastLineWidth = 0;
    
		log_message('debug', 'prunus_damasco inicializado');
	}
	
  private function bufferClear() { $this->buffer = ''; }
  private function bufferAdd($position, $text) { $this->buffer .= $this->ci->prunus_core->gi ( ($this->offsetPosition + $position), $text); }
  
  public function open ($title, $mensaje, $close, $trigger, $offset = -1) {
    if ($offset != -1) $this->$offsetPosition = $offset;
    $this->title = $title;
    $this->msg = $mensaje;
    $this->triggerLabel = $trigger;
    $this->closeLabel = $close;
  } //open
  
  public function renderTrigger() {
    $this->bufferClear();
    $this->bufferAdd(0, "<div id=\"PRDA_trigger\">" . $this->triggerLabel . "</div>");
    return $this->buffer;
  }
  public function renderMessage() {
    $this->bufferClear();
    $this->bufferAdd(0, "<div id=\"PRDA_wnd\">");
    $this->bufferAdd(2, "<a id=\"PRDA_close\">" . $this->closeLabel . "</a>");
    $this->bufferAdd(2, "<div class=\"PRDA_title\">" . $this->title . "</div>");
    $this->bufferAdd(2, "<div id=\"PRDA_data\">");
    $this->bufferAdd(4, $this->msg);
    $this->bufferAdd(2, "</div>");
    $this->bufferAdd(0, "</div>");
    $this->bufferAdd(0, "<div id=\"PRDA_bkg\">");
    $this->bufferAdd(0, "</div>");
    return $this->buffer;
  } //render
  
}
